#### load open-ended data
load("~/Dropbox/NAES/oe-consolidated-data-04272022.Rdata")
dim(dta.w15.joint.sub)
length(unique(dta.w15.joint.sub$MNO))
dta.w15.joint.sub$MNO <- NULL

biden.vec <- round(apply(dta.w15.joint.sub[dta.w15.joint.sub$VP5_A_1_15.x=="Joe Biden, the Democrat",
                                           which(sapply(dta.w15.joint.sub,is.numeric))],2,mean.na),digits=3)

trump.vec <- round(apply(dta.w15.joint.sub[dta.w15.joint.sub$VP5_A_1_15.x=="Donald Trump, the Republican",
                                           which(sapply(dta.w15.joint.sub,is.numeric))],2,mean.na),digits=3)

tt2 <- cbind(trump.vec,biden.vec)
tt3 <- t(tt2)

colnames(tt3) <- c("Traits","Experience","Policies",
                   "Performance","Opposition",
                   "Slogans","Ideology",
                   "Disaffection")

xtable(tt3,digits=c(0,rep(2,8)))

tt4 <- t(cbind(rep(0,8),rep(0,8)))
colnames(tt4) <- colnames(tt3)

#jpeg(file="~/Dropbox/NAES/figures/oe-vote-04212021.jpg",width=720)
barplot(tt3,beside=T,cex.main=1.5,
        main="Open-Ended Vote Explanations",ylim=c(0,.55))
text(14.8,y=.4,"Biden",cex=1.5)
text(8,.35,"Trump",cex=1.5)
#dev.off()